package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.GoodsBean;
import com.project.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private IGoodsService service;

    @RequestMapping("add")
    public String add(GoodsBean goods){
        service.add(goods);
        return "ok";
    }

    @RequestMapping("del")
    public String del(Integer id){
        service.del(id);
        return "ok";
    }

    @RequestMapping("update")
    public String update(Integer id,Integer price){
        service.update(id,price);
        return "ok";
    }

    @RequestMapping("findById")
    public GoodsBean findById(Integer id){
        return service.findById(id);
    }

    @RequestMapping("findByItem")
    public IPage<GoodsBean> findByItem(Integer pageNO,
            String name, LocalDate startDate,LocalDate endDate){
        return service.findByItem(pageNO,name,startDate,endDate);
    }
}
